import ToolRequest from '@/base/newToolAxios';
import RequestOption from '@/base/RequestOption';
import { getActToolUrl } from '@/base/constant';
const tr = new ToolRequest();

export default class TeachingClassDao {
  /**
   * 根据课程ID列表获取班级、小组和学生
   * @return 班级列表
   */
  async findClassByCourseId(courseId: number) {
    const ro = new RequestOption();
    return await tr.get(
      getActToolUrl(),
      {
        action: 'findProjectClassesAndTeamsByCourseId',
        courseId: courseId
      },
      ro
    );
  }

  async addClass(courseId: number, className: string) {
    const ro = new RequestOption();
    return await tr.post(
      getActToolUrl(),
      {
        action: 'addProjectClass',
        courseId: courseId,
        className: className
      },
      ro
    );
  }
  async deleteClass(classId: number) {
    const ro = new RequestOption();
    return await tr.post(
      getActToolUrl(),
      {
        action: 'deleteProjectClass',
        classId: classId
      },
      ro
    );
  }

  async addClassStudentRef(classId: number, studentIds: Array<number>) {
    const ro = new RequestOption();
    return await tr.post(
      getActToolUrl(),
      {
        action: 'addClassStudentRef',
        classId: classId,
        studentIds: studentIds.join(',')
      },
      ro
    );
  }

  async deleteClassStudentRef(classId: number, studentIds: Array<number>) {
    const ro = new RequestOption();
    return await tr.post(
      getActToolUrl(),
      {
        action: 'deleteClassStudentRef',
        classId: classId,
        studentIds: studentIds.join(',')
      },
      ro
    );
  }
}
